package com.regvision.contacts.main;

import com.regvision.contacts.R;
import com.regvision.contacts.ui.MainActivity;
import com.regvision.contacts.utils.SharedPrefUtil;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;


public class SplashActivity extends Activity {

	private final int SPLASH_DISPLAY_LENGHT = 3000; 

	private Context context;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);

		startApp();
	}

	private void startApp() {

		new Handler().postDelayed(new Runnable() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				finish();
				
				if (SharedPrefUtil.getString(SplashActivity.this, "username", null) == null) {
		        	startActivity(new Intent(SplashActivity.this, InitActivity.class));
		        } else {
					startActivity(new Intent(SplashActivity.this, MainActivity.class));
				}

			}
		}, SPLASH_DISPLAY_LENGHT);
	}

}
